package com.vx.cloud.dataCloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 提供对外服务的接口类
 * Created by aofavx on 2017-8-8.
 */
//自动更新服务器的最新配置信息
@RefreshScope
@RestController
public class TestController {

    @Autowired
    DiscoveryClient discoveryClient;

    //自动获取配置文件中的值
    @Value("${form}")
    private String form;

    @RequestMapping("/form")
    public String form() {
        return this.form;
    }

    @GetMapping("/dc")
    public String dc(){
        String services = "Services: " + discoveryClient.getServices();
        System.out.println(services);
        return services;
    }
}
